<?php

/**
 * This is the model class for table "zy_event_step".
 *
 * The followings are the available columns in table 'zy_event_step':
	 * @property integer $step_id
	 * @property string $event_field
	 * @property string $email_templet
	 * @property string $message_templet
 */
class EventStep extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return EventStep the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'zy_event_step';
	}
	public function primaryKey()
	{
		return 'step_id';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('email_template, message_template,remark', 'length', 'max'=>255),
			array('step', 'numerical', 'integerOnly'=>true),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('step_id,event_id, event_field, email_template, message_template,step, is_delete, remark, create_time, create_user, update_time, update_user', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'step_id' =>Yii::t("EventStep","Step ID"),
			'event_id' =>Yii::t("EventStep","Event ID"),
			'event_field' =>Yii::t("EventStep","Event Field"),
			'email_template' =>Yii::t("EventStep","Email Template"),
			'message_template' =>Yii::t("EventStep","Message Template"),
			'step' =>Yii::t("EventStep","Step"),
			'is_delete' =>Yii::t("EventStep","Is Delete"),
			'remark' =>Yii::t("EventStep","Remark"),
			'create_time' =>Yii::t("EventStep","Create Time"),
			'create_user' =>Yii::t("EventStep","Create User"),
			'update_time' =>Yii::t("EventStep","Update Time"),
			'update_user' =>Yii::t("EventStep","Update User"),
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('step_id',$this->step_id);
		$criteria->compare('event_id',$this->event_id);
		$criteria->compare('event_field',$this->event_field,true);
		$criteria->compare('email_template',$this->email_template,true);
		$criteria->compare('message_template',$this->message_template,true);
		$criteria->compare('step',$this->step);
		$criteria->compare('is_delete',$this->is_delete);
		$criteria->compare('remark',$this->remark,true);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('create_user',$this->create_user,true);
		$criteria->compare('update_time',$this->update_time,true);
		$criteria->compare('update_user',$this->update_user,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
			'sort'=>array(  
           		 'defaultOrder'=>'step_id DESC',  
       		 ),  
       		'pagination'=>array(  
           		 'pageSize'=>20  
       		 ),  
		));
	}
	
		public function search2($event_id)
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('step_id',$this->step_id);
		$criteria->compare('event_id',$event_id);
		$criteria->compare('event_field',$this->event_field,true);
		$criteria->compare('email_template',$this->email_template,true);
		$criteria->compare('message_template',$this->message_template,true);
		$criteria->compare('step',$this->step);
		$criteria->compare('is_delete',$this->is_delete);
		$criteria->compare('remark',$this->remark,true);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('create_user',$this->create_user,true);
		$criteria->compare('update_time',$this->update_time,true);
		$criteria->compare('update_user',$this->update_user,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
			'sort'=>array(  
           		 'defaultOrder'=>'step_id DESC',  
       		 ),  
       		'pagination'=>array(  
           		 'pageSize'=>20  
       		 ),  
		));
	}
}